package org.wu.mp.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.wu.mp.domain.Employee;
import org.wu.mp.mapper.EmployeeMapper;
import org.wu.mp.query.EmployeeQuery;
import org.wu.mp.service.IEmployeeService;

/**
 * mybatis-plus服务层接口实现类
 * 1 > 自定一个类EmployeeServiceImpl 继承ServiceImpl 实现自定义服务接口IEmployeeService
 * 2 > 在ServiceImpl 上明确指定2个泛型
 *      1> 当前操作实体对象对应mapper接口EmployeeMapper
 *      2> 当前操作实体对象Employee
 */
@Service // 告诉springmvc说我这个是一个service组件
@Transactional //声明事务控制
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements IEmployeeService{
    @Override
    public Page<Employee> queryPage(EmployeeQuery qo) {

        // 创建查询条件
        QueryWrapper<Employee> wrapper = new QueryWrapper<>();
        // 创建分页
        Page<Employee> page = new Page<>(qo.getCurrentPage(), qo.getPageSize());
        // 模糊匹配
        wrapper.like("name",qo.getKeyword());

//        return getBaseMapper().selectPage(page,wrapper);
        return super.page(page,wrapper); // 返回查询结果
    }
}
